package com.bos.controller;

import com.bos.common.ResultData;
import com.bos.data.model.BosUserModel;
import com.bos.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpSession;

/**
 * create by luojie 2018/6/9
 */
@RestController
public class LoginController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/loginTest")
    public ResultData login(@ModelAttribute BosUserModel user, HttpSession session, Model model, RedirectAttributes attr){
        ResultData result=new ResultData();
        BosUserModel u = userService.login(user);
        if(u==null){
            //获得该用户的权限
            return userService.getRole(6);
        }
        result.setMessage("用户无权限");
        result.setResult("false");
        return result;
    }
}
